home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / 3_0 / CUTILSLI / UTILITYL / RAND.C < prev    next >
Text File  |  1987-11-10  |  1KB  |  35 lines

  1.     /*********************************************
  2.     *    Filename:    Rand.c                                                                 
  3.     *    Purpose:    Random Number Generator                      
  4.     *    Authors:    Robert E. Neville                                                       
  5.     *    Date:        November 10, 1987                                                        
  6.     *    Functions:     Rand().    
  7.     *    Version        1.0a                                                                            
  8.     *    Copyright   1987    Hummingbird Graphics                                  
  9.     *********************************************/
  10.  
  11.     extern long    randSeed;            /* Extern global from Mactraps */
  12.  
  13.     /**********************************
  14.     *    Function:    Rand(div)
  15.     *    Purpose:    Generate a random #
  16.     *    Passed:        unsigned int - div
  17.     *    Returned:    int        num                                        
  18.     ***********************************/
  19.  
  20.     int Rand(div)
  21.     unsigned int    div;
  22.     {
  23.         static int    done = 0;        /* Static so we only do this once */
  24.         int            num;            /* the number */
  25.     
  26.         if (!done)                    /* we haven't done this before */
  27.         {
  28.             GetDateTime(&randSeed);    /* store number of seconds in randSeed */
  29.             done = 1;                /* don't do it again */
  30.         }
  31.         num = Random();                /* get a random number */
  32.         return(num % div);            /* in range 0 - div */
  33.     }                                /* end of Rand */
  34.  
  35.     /***********    End of File     ***********/